{
 "cells": [
  {
   "cell_type": "code",
   "id": "ac5a2183f1735a53",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-07-31T06:56:11.679476Z",
     "start_time": "2025-07-31T06:56:04.611762Z"
    }
   },
   "source": [
    "from langchain_core.messages import HumanMessage, SystemMessage\n",
    "from init_llm_model import *\n",
    "\n",
    "messages = [\n",
    "    SystemMessage(\"Translate the following from English into Italian\"),\n",
    "    HumanMessage(\"hi!\"),\n",
    "]\n",
    "\n",
    "print(llm.invoke(messages))"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "content='Ciao!  \\n\\n(Note: \"Ciao\" is a common and friendly way to say \"hi\" or \"bye\" in Italian, suitable for informal situations. If you\\'d like a more formal greeting, you could use \"Salve!\")  \\n\\nLet me know if you\\'d like help with anything else! 😊' additional_kwargs={'refusal': None} response_metadata={'token_usage': {'completion_tokens': 66, 'prompt_tokens': 12, 'total_tokens': 78, 'completion_tokens_details': None, 'prompt_tokens_details': {'audio_tokens': None, 'cached_tokens': 0}, 'prompt_cache_hit_tokens': 0, 'prompt_cache_miss_tokens': 12}, 'model_name': 'deepseek-chat', 'system_fingerprint': 'fp_8802369eaa_prod0623_fp8_kvcache', 'id': '9245a536-8fd1-4755-bcd3-3e5676fa91e6', 'service_tier': None, 'finish_reason': 'stop', 'logprobs': None} id='run--215c0c35-f010-481f-8580-06bbff49421d-0' usage_metadata={'input_tokens': 12, 'output_tokens': 66, 'total_tokens': 78, 'input_token_details': {'cache_read': 0}, 'output_token_details': {}}\n"
     ]
    }
   ],
   "execution_count": 3
  },
  {
   "cell_type": "code",
   "id": "c3a321a6358cb8b9",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-07-31T06:58:32.064751Z",
     "start_time": "2025-07-31T06:58:32.032720Z"
    }
   },
   "source": [
    "from langchain_core.prompts import ChatPromptTemplate\n",
    "\n",
    "system_template = \"Translate the following from English into {language}\"\n",
    "\n",
    "prompt_template = ChatPromptTemplate.from_messages(\n",
    "    [(\"system\", system_template), (\"user\", \"{text}\")]\n",
    ")"
   ],
   "outputs": [],
   "execution_count": 4
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-07-31T06:58:33.177405Z",
     "start_time": "2025-07-31T06:58:33.171604Z"
    }
   },
   "cell_type": "code",
   "source": [
    "prompt = prompt_template.invoke({\"language\": \"Italian\", \"text\": \"hi!\"})\n",
    "print(prompt)"
   ],
   "id": "596ea6ee1c963dcb",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "messages=[SystemMessage(content='Translate the following from English into Italian', additional_kwargs={}, response_metadata={}), HumanMessage(content='hi!', additional_kwargs={}, response_metadata={})]\n"
     ]
    }
   ],
   "execution_count": 5
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "prompt.to_messages()",
   "id": "4c59fc05015343a3"
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": [
    "response = llm.invoke(prompt)\n",
    "print(response.content)"
   ],
   "id": "b5ed6e4520ad138f"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
